<?php


namespace Part20_IteratorMode\Code1;


class ConcreteAggregate extends Aggregate
{
    /**
     * 存储聚合对象
     * @var array
     */
    private $items;

    public function createIterator()
    {
        return new ConcreteIterator($this);
    }

    public function getCount()
    {
        return count($this->items);
    }

    public function setItem($value)
    {
        $this->items[] = $value;
    }

    public function getItem($index)
    {
        return $this->items[$index];
    }
}